(require 'cl)
(setq TeX-view-style '( ("." "yap -1 %dS %d")))
(setq TeX-output-view-style
      '( ("^dvi$" "." "yap -1 %dS %d")))

(eval-after-load "tex"
  '(progn
     (TeX-global-PDF-mode t)));tex pdf-mode

(setq my-tex-commands-extra (list 
	(list "dvipdfmx" "dvipdfmx %s.dvi" 'TeX-run-command nil t)
	(list "gbk2uni" "gbk2uni %s.out" 'TeX-run-command nil t)))

(setq TeX-command-list
'(("TeX" "tex %s.tex" TeX-run-TeX nil (plain-tex-mode))
("LaTeX" "latex %s.tex" TeX-run-TeX nil (latex-mode))
("Dvips" "dvips %d -o %f " TeX-run-command nil t)
("ps2pdf" "ps2pdf %f %s.pdf" TeX-run-command nil t)
("DFLaTeX" "pdflatex %s.tex" TeX-run-TeX nil (latex-mode))
("View" "xdvi %d" TeX-run-command nil t) ;TeX-run-discard
("gv" "gv %f" TeX-run-command nil t)
("Xpdf" "xpdf %s.pdf" TeX-run-command nil t)
("ConTeXt" "texexec --once --nonstop --texutil %t" TeX-run-TeX nil (context-mode))
("ConTeXt PDF" "texexec --pdf %t" TeX-run-TeX nil (context-mode))
("ConTeXt Interactive" "texexec --once --texutil %t" TeX-run-interactive t (context-mode))
("ConTeXt Full" "texexec %t" TeX-run-interactive nil (context-mode))
("ConTeXt Clean" "texutil --purgeall" TeX-run-interactive nil (context-mode))
("BibTeX" "bibtex %s" TeX-run-BibTeX nil t)
("Index" "makeindex %s" TeX-run-command nil t)
("Check" "lacheckw32 %s" TeX-run-compile nil t)
("gbk2uni" "gbk2uni %s.out" TeX-run-command nil t)
))
;(setq TeX-command-default "pdflatex")
;
;add dvipdf to command


(add-hook 'LaTeX-mode-hook 'turn-on-reftex) 
(autoload 'cdlatex-mode "cdlatex" "CDLaTeX Mode" t)
(autoload 'turn-on-cdlatex "cdlatex" "CDLaTeX Mode" nil)
(add-hook 'LaTeX-mode-hook 'turn-on-cdlatex)
;; (add-hook 'latex-mode-hook 'turn-on-cdlatex);autoload cdlatex
;using acroread
;(key-binding "\C-o \?")


(add-hook 'TeXinfo-mode-hook 'outline-minor-mode)
(add-hook 'LaTeX-mode-hook 'outline-minor-mode)
;;preview
(setq preview-auto-cache-preamble t)
;;latex-mode for yasnippet
(yas/define-snippets 'latex-mode
'(
  ("arr" "\\left ${1:}\\begin\{array\}\{${2:c l r}\}
$3 & 
\\end\{array\}\\right $6" "array" nil nil)
  ("lab" "\\label{eq:$0}" "label" nil nil)
  ("pma" "\\begin\{pmatrix\}
$2 & 
\\end\{pmatrix\}" "pmatrix" nil nil)
  ("bma" "\\begin\{bmatrix\}
$2 & 
\\end\{bmatrix\}" "bmatrix" nil nil)
  ("Bma" "\\begin\{Bmatrix\}
$2 & 
\\end\{Bmatrix\}" "Bmatrix" nil nil)
  ("vma" "\\begin\{vmatrix\}
$2 & 
\\end\{vmatrix\}" "vmatrix" nil nil)
  ("Vma" "\\begin\{Vmatrix\}
$2 & 
\\end\{Vmatrix\}" "Vmatrix" nil nil)
  ("ket" "|$0\\rangle "
   "|>" nil nil)
  ("bra" "\\langle $0|"
   "<|" nil nil)
;  ("fr"  "\\frac\{$1\}\{$2\}$0"
;"frac" nil nil)
  ("vec" "\\vec\{$0\}"
   "vector" nil nil)

  ("sum" "\\sum_\{$0\}^\{\}"
   "sum" nil nil)
  ("int" "\\int_\{$0\}^\{\}"
   "int" nil nil)
  ("aa" "a_\{${1:}_\{${2:}\}\}(\\bar\{$1\}_\{$2\})"
   "aa" nil nil)
  ("as" "a^{*}_\{${1:}_\{${2:}\}\}(\\bar\{$1\}_\{$2\})"
   "astar" nil nil)
  ("sket" "|$1^\{$2\}$3_\{$4}\\rangle"
   "ket with q number" nil nil)
  ("sbra" "\\langle $1^\{$2\}$3_\{$4\}|"
   "bra with q number" nil nil)
  ("cos" "\\cos\{\\theta_\{$0\}\}"
   "cos" nil nil)
  ("sin" "\\sin\{\\theta_\{$0\}\}"
   "sin" nil nil)
  ("pro" "\\propto"
   "propto" nil nil)
  ("spl" "\\begin\{equation\}
\$0
\\begin\{split\}

\\end\{split\}
\\end\{equation\}"
"split" nil nil)
  ("ali" "\\begin\{align\}
$0
\\end\{align\}"
"align" nil nil)
  ("equ" "\\begin\{equation\}
\$1
$0
\\end\{equation\}"
"equation" nil nil)
  ("re" "[\\ref\{eq$1\}]"
"ref" nil nil)
))
(setq preview-scale-function 1.25)
(provide 'latexmodel)